package blue.qingyu.whimurmur.lookBack.directive;

import java.util.List;

import com.jfinal.aop.Inject;
import com.jfinal.template.Env;
import com.jfinal.template.io.Writer;
import com.jfinal.template.stat.Scope;

import blue.qingyu.whimurmur.lookBack.model.LookBackLine;
import blue.qingyu.whimurmur.lookBack.service.LookBackLineServiceProvider;
import io.jboot.db.model.Columns;
import io.jboot.web.directive.annotation.JFinalDirective;
import io.jboot.web.directive.base.JbootDirectiveBase;

/**
 * @author zhangxr
 * @Title:
 * @Package
 * @Description:
 * @date 2020/6/13 21:52
 */
@JFinalDirective("trace")
public class LookBackDirective extends JbootDirectiveBase {

    @Inject
    private LookBackLineServiceProvider traceLineService;

    @Override
    public void onRender(Env env, Scope scope, Writer writer) {
        Integer id = getParaToInt("id", scope);
        // 修改
        List<LookBackLine> lines = traceLineService.findListByColumns(Columns.create("trace_header_id", id), "id");
        scope.setLocal("lines", lines);
        renderBody(env, scope, writer);
    }

    @Override
    public boolean hasEnd() {
        return true;
    }
}
